<?php
/* @var $this yii\web\View */

use yii\widgets\LinkPager;
$this->title = $tag->name;
$this->params['breadcrumbs'][] = ['label' => '标签', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="qa-tag">
    <h3><?php echo $tag->name ?></h3>
    <ul id="myTab" class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a>问答</a></li>
        <li role="presentation" class=""><a href="/tags/article?id=<?php echo $tag->id ?>" >文章</a></li>
    </ul>
    <table class="table">
        <tbody>
            <?php foreach ($qa_list as $row): ?>
                <tr>
                    <td class="w50"><div class="<?php echo $row->qa->comments ? 'answers' : 'no-answers' ?>"><?php echo $row->qa->comments; ?><small>回答</small></div></td>
                    <td class="w50"><div class="views"><?php echo $row->qa->view; ?><small>浏览</small></div></td>
                    <td>
                        <span><?php echo $row->qa->author->username ?> &nbsp;&nbsp;<?php echo Yii::$app->formatter->asRelativeTime($row->qa->created_at) ?>&nbsp;发布</span><br>
                        <a href="/qa/view?id=<?php echo $row->qa->id ?>"><?php echo $row->qa->title; ?></a>
                        <?php foreach ($row->qa->tags($row->qa->id) as $item): ?>
                            <a class="btn btn-success btn-xs" href="/tags/show?id=<?php echo $item->id ?>" role="button"><?php echo $item->name ?></a>
                        <?php endforeach; ?>
                    </td>
                </tr>
            <?php endforeach; ?>

            <?php echo LinkPager::widget(['pagination' => $pages]); // 显示分页?>
        </tbody>
    </table>
</div>
